package com.business.form.service;

import java.util.List;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.business.system.common.base.BaseService;
import com.business.system.common.support.Convert;
import com.business.form.mapper.auto.FormFieldInfoValueMapper;
import com.business.form.model.auto.FormFieldInfoValue;
import com.business.form.model.auto.FormFieldInfoValueExample;
import com.business.system.model.custom.Tablepar;
import com.business.system.util.SnowflakeIdWorker;

/**
 * 表单字段value FormFieldInfoValueService
 * @Title: FormFieldInfoValueService.java 
 * @Package com.business.form.service 
 * @author lujingyuan_自动生成
 * @email 674326842@qq.com
 * @date 2020-06-18 14:54:47  
 **/
@Service
public class FormFieldInfoValueService implements BaseService<FormFieldInfoValue, FormFieldInfoValueExample>{
	@Autowired
	private FormFieldInfoValueMapper formFieldInfoValueMapper;
	
      	   	      	      	      	      	      	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<FormFieldInfoValue> list(Tablepar tablepar,String name){
	        FormFieldInfoValueExample testExample=new FormFieldInfoValueExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andFieldValueLike("%"+name+"%");
	        }

	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<FormFieldInfoValue> list= formFieldInfoValueMapper.selectByExample(testExample);
	        PageInfo<FormFieldInfoValue> pageInfo = new PageInfo<FormFieldInfoValue>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			FormFieldInfoValueExample example=new FormFieldInfoValueExample();
			example.createCriteria().andIdIn(lista);
			return formFieldInfoValueMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public FormFieldInfoValue selectByPrimaryKey(String id) {
				
			return formFieldInfoValueMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(FormFieldInfoValue record) {
		return formFieldInfoValueMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(FormFieldInfoValue record) {
				
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return formFieldInfoValueMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(FormFieldInfoValue record, FormFieldInfoValueExample example) {
		
		return formFieldInfoValueMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(FormFieldInfoValue record, FormFieldInfoValueExample example) {
		
		return formFieldInfoValueMapper.updateByExample(record, example);
	}

	@Override
	public List<FormFieldInfoValue> selectByExample(FormFieldInfoValueExample example) {
		
		return formFieldInfoValueMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(FormFieldInfoValueExample example) {
		
		return formFieldInfoValueMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(FormFieldInfoValueExample example) {
		
		return formFieldInfoValueMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param formFieldInfoValue
	 * @return
	 */
	public int checkNameUnique(FormFieldInfoValue formFieldInfoValue){
		FormFieldInfoValueExample example=new FormFieldInfoValueExample();
		example.createCriteria().andFieldValueEqualTo(formFieldInfoValue.getFieldValue());
		List<FormFieldInfoValue> list=formFieldInfoValueMapper.selectByExample(example);
		return list.size();
	}


}
